instantiate

open fun instantiate(@NonNull context: Context, @NonNull fname: String): Fragment(source)

Like instantiate but with a null argument Bundle.


open fun instantiate(@NonNull context: Context, @NonNull fname: String, @Nullable args: Bundle): Fragment(source)

Deprecated

Use getFragmentFactory and instantiate, manually calling setArguments on the returned Fragment.

Create a new instance of a Fragment with the given class name. This is the same as calling its empty constructor, setting the ClassLoader on the supplied arguments, then calling setArguments.

Return

Returns a new fragment instance.

Parameters

context

The calling context being used to instantiate the fragment. This is currently just used to get its ClassLoader.

fname

The class name of the fragment to instantiate.

args

Bundle of arguments to supply to the fragment, which it can retrieve with getArguments. May be null.

Throws

If there is a failure in instantiating the given fragment class. This is a runtime exception; it is not normally expected to happen.